layui.define(['layer','jquery'], function(exports){ 
    var $ = layui.jquery
    ,layer=layui.layer

    ,obj = {
        //common.hello(str)
        hello: function(str){
          layer.msg('Hello '+ (str||'mymod'));
        }

        //common.test.test()
        //common.test.test2
        ,test:{
            test:function(str){
                layer.msg(str);
            }
            ,test2:'333'
        }
        ,ajax: function (url, data, callback) {
            $.ajax({
                url: url
                ,contentType: 'application/json'
                ,type:'POST' 
                ,dataType:'json' 
                ,data:JSON.stringify(data)
                ,success: callback
            });
        }
        //批量重写input val值{name:val}
        ,wVal:function(data){
            for (var key in data){
                $( "input[name='"+key+"']").val(data[key])
            }    
        }

    };

    //输出接口
    exports('common', obj);
});
